<template>
  <div>
    <h1>订单详情</h1>
    <p>订单ID: {{ order.id }}</p>
    <p>总金额: {{ order.totalAmount }}</p>
    <p>状态: {{ order.status }}</p>
    <p>收货地址: {{ order.shipping_address }}</p>
    <el-table :data="orderItems" style="width: 100%">
      <el-table-column prop="productName" label="商品名称"></el-table-column>
      <el-table-column prop="quantity" label="数量"></el-table-column>
    </el-table>
  </div>
</template>

<script>
import { getOrderDetail } from '@/api/order';

export default {
  data() {
    return {
      order: {},
      orderItems: [],
    };
  },
  methods: {
    async fetchOrder() {
      const response = await getOrderDetail(this.$route.params.id);
      this.order = response.data;
      this.orderItems = response.data.items; // 假设订单详情中包含商品列表
    },
  },
  mounted() {
    this.fetchOrder();
  },
};
</script>